﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>字符串小写 / 字符串大写 - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The 字符串小写 and 字符串大写 functions converts a 字符串 to lowercase or uppercase." />
<meta name="ahk:equiv-v1" content="commands/StringLower.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>字符串小写 / 字符串大写</h1>

<p>将字符串转换为小写或大写.</p>

<pre class="Syntax">NewString := <span class="func">字符串小写</span>(字符串 <span class="optional">, "T"</span>)
NewString := <span class="func">字符串大写</span>(字符串 <span class="optional">, "T"</span>)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>字符串</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>要转换的字符串.</p>
  </dd>
  
  <dt>T</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>如果此参数为字母 T, 那么字符串会被转换为标题格式. 例如, &quot;GONE with the WIND&quot; 会被转换成 &quot;Gone With The Wind&quot;.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
<p>这些函数返回指定字符串转换后的新版本.</p>

<h2 id="Remarks">备注</h2>
<p>要判断一个字符或字符串是完全大写还是小写, 请使用 <a href="Is.htm#upper">是否大写</a>, <a href="Is.htm#lower">是否小写</a> 或 <a href="RegExMatch.htm">正则匹配</a> 函数. 例如:</p>
<pre>变量 := "abc"
如果 是否大写(var)
    信息框 "var is empty or contains only uppercase characters."
如果 是否小写(var)
    信息框 "var is empty or contains only lowercase characters."
如果 正则匹配(var, "^[a-z]+$")
    信息框 "var is not empty and contains only lowercase ASCII characters."
如果 !正则匹配(var, "[A-Z]")
    信息框 "var does not contain any uppercase ASCII characters."</pre>

<p><a href="Format.htm">格式化字符串</a> 也能实现大小写变换, 如下所示:</p>
<pre>信息框 格式化字符串("{:U}, {:L} and {:T}", "upper", "LOWER", "title")</pre>

<h2 id="Related">相关</h2>
<p><a href="InStr.htm">查找</a>, <a href="SubStr.htm">截取字符串</a>, <a href="StrLen.htm">字符串长度</a>, <a href="StrReplace.htm">字符串替换</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>String1 := 字符串大写(String1)  <em>; 即输出可以和输入相同.</em>
String2 := 字符串小写("ABC")  <em>; String2 为 "abc"</em></pre>
</div>

</body>
</html>